import { baseUrl } from '../../api/config'
Page({
  data: {
    url: ''
  },
  loadUrl (preUrl, query) {
    const token = wx.getStorageSync('token')
    const url = `${baseUrl}${preUrl}?token=${token}${query}&stamp=${new Date().getTime()}`
    // const list = preUrl.split('#')
    // preUrl = `/#${list[1]}`
    // const url = `http://192.168.3.127:8080/${preUrl}?token=${token}${query}&stamp=${new Date().getTime()}`
    this.setData({ url })
  },
  onLoad (options) {
    const preUrl = options.url
    delete options.url
    let query = ''
    for (let key in options) {
      query += `&${key}=${options[key]}`
    }
    this.loadUrl(preUrl, query)
  }
})